<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.ArrayList, java.util.List"%>
<%@page pageEncoding="utf-8"%>
<%@page import="java.sql.*, com.liangjie.bbs.*"%>

<%
	int pageNum;
	int pageSize = 4;
	int recordSum = 0;
	int pageSum = 0;

	String strPageNum = request.getParameter("pageNum");
	if (strPageNum == null || strPageNum.equals("")) {
		pageNum = 1;
	} else {
		try {
			pageNum = Integer.parseInt(strPageNum);
		} catch (NumberFormatException e) {
			pageNum = 1;
		}
		if (pageNum <= 0) {
			pageNum = 1;
		}
	}
	List<Article> articles = new ArrayList<Article>();
	Connection conn = DB.getConn();
	Statement stmt = DB.getStmt(conn);

	ResultSet record = DB.executeQuerey(stmt,
			"select count(*) from article where pid = 0");
	record.next();
	recordSum = record.getInt(1);
	pageSum = recordSum % pageSize == 0 ? recordSum / pageSize
			: recordSum / pageSize + 1;
	if (pageNum > pageSum)
		pageNum = pageSum;
	int startPos = (pageNum - 1) * pageSize;

	String sql = "select * from article where pid = 0 order by pdata desc limit "
			+ startPos + "," + pageSize;
	ResultSet rs = DB.executeQuerey(stmt, sql);

	while (rs.next()) {
		Article article = new Article();
		article.initFromJsp(rs);
		articles.add(article);
	}

	DB.close(rs);
	DB.close(stmt);
	DB.close(conn);
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0040)http://cn.club.vmall.com/forumall-1.html -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>主题列表——平板展现</title>

<link rel="stylesheet" type="text/css"
	href="./sources/article/style_5_common.css" />
</head>
<body>
	<div id="wp" class="wp">
		<div id="wp" class="wp">
			<div class="boardnav">
				<div id="ct" class="wp cl ct2">
					<div class="mtw">
						<div class="bm bml thd-tags">
							<div class="thdtag-poll mkclearfix">
								<h2>BBS论坛——平板展现</h2>
							</div>
							<div class="thdpp-sub">
								<p>欢迎光临，本页面来自华为花粉俱乐部！</p>
							</div>
						</div>
						<%
							Iterator<Article> it = articles.iterator();
							while (it.hasNext()) {
								Article article = it.next();
						%>
						<div id="threadlist" class="tl thd_bmw">
							<div class="bm_c thd_bm">
								<div id="forumnew" style="display:none"></div>
								<form method="post" name="moderate" id="moderate"
									action="http://cn.club.vmall.com/forum.php?mod=topicadmin&action=moderate&fid=0&infloat=yes&nopost=yes">
									<table summary="forum_0" cellspacing="0" cellpadding="0"
										id="threadlisttableid">
										<tbody id="stickthread_4641783">
											<tr>
												<th class="common">
													<div class="avatarbox">
														<img src="./sources/article/bagua.png" alt="头像" />
													</div>
													<div class="thdpp-cont">
														<a
															href="./article_detail_flat.jsp?id=<%=article.getId()%>"
															style="font-weight: bold;color: #EE1B2E;"
															onclick="atarget(this)" class="s xst"><%=article.getTitle()%></a>
														<img src="./sources/article/pin_3.gif" alt="全局置顶" /> <img
															src="./sources/article/rushreply_s.png" alt="抢楼" /> <span
															id="rushtimer_4641783"> 【还有 <span
															id="rushtimer_body_4641783">3天7小时33分39秒</span> 结束 】
														</span> <img src="./sources/article/image_s.gif" alt="attach_img"
															title="图片附件" /> <span class="tps" style="display:none;">&nbsp;...<a
															href="http://cn.club.vmall.com/thread-4641783-2-1.html">2</a><a
															href="http://cn.club.vmall.com/thread-4641783-3-1.html">3</a><a
															href="http://cn.club.vmall.com/thread-4641783-4-1.html">4</a><a
															href="http://cn.club.vmall.com/thread-4641783-5-1.html">5</a><a
															href="http://cn.club.vmall.com/thread-4641783-6-1.html">6</a><a
															href="http://cn.club.vmall.com/thread-4641783-1677-1.html">temp</a></span>
														<div class="thd-sinfo">
															<span class="thd-ico thd-replies">查看：16765</span> <em>
																<a
																href="http://cn.club.vmall.com/space-uid-8157381.html">LiangJie
																	<img src="./sources/article/v.png" />
															</a>
															</em> <em> 于 <span><span title="2015-6-15"><%=new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss")
						.format(article.getpDate())%>&nbsp;发表</span></span> 最后回复 <span><span
																	title="2015-6-19 16:24">1&nbsp;秒前</span></span></em>
														</div>
													</div>

												</th>
											</tr>
										</tbody>
									</table>
									<!-- end of table "forum_G[fid]" branch 1/3 -->
								</form>
							</div>
						</div>
						<%
							}
						%>
						<div class="bm pgs cl hbp-pager mkclearfix">
							<span id="fd_page_bottom" />
							<div class="pg">
								<!--strong>1</strong-->
								<%
									for (int i = 1; i <= pageSum; i++) {
										if (pageNum == i) {
								%>
								<strong><%=i%></strong>
								<%
									} else {
								%>
								<a href="./articleflat.jsp?pageNum=<%=i%>"><%=i%></a>

								<%
									}
									}
								%>
								<a class="last">第<%=pageNum%>页 共<%=pageSum%>页
								</a> <a href="./articleflat.jsp?pageNum=<%=pageNum + 1%>"
									class="nxt">下一页</a>
							</div>
							<span id="visitedforumstmp" class="mkbtn-blue newpost" /><a
								href="./post.jsp?from=flat"><font color="white">发布新帖</font></a>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div id="ft" class="wp cl">
		<div id="flk" class="wp mk-box">
			<p>
				Copyright © 2011-2013 华为软件技术有限公司 版权所有 保留一切权利 <a href="#"
					target="_blank">苏网文[2012]0401-019号</a>
			</p>
		</div>
	</div>
</body>
</html>
